from actuator import Solver
from utils.param import Param
import streamlit as st
import re

if __name__ == '__main__':
    param = Param()
    solver = Solver(param)
    # solver.train()

    st.title('唐诗宝典')
    with st.form('myform'):
        topic_text1 = st.text_input('输入提示词续写首句:', '')
        submitted1 = st.form_submit_button('Submit1')
        topic_text2 = st.text_input('输入提示词续写藏头诗:', '')
        submitted2 = st.form_submit_button('Submit2')
        if submitted1:
            st.markdown(re.sub(r'\n', '<br>', solver.generate_continuation(start_words=topic_text1)), unsafe_allow_html=True)
        if submitted2:
            st.markdown(re.sub(r'\n', '<br>', solver.generate_acrostic_poetry(start_words=topic_text2)), unsafe_allow_html=True)
# streamlit run run.pyls